package com.atwisdom.star.controller;

import com.alibaba.fastjson.JSONObject;
import com.atwisdom.star.common.vo.ActionData;
import com.atwisdom.star.common.vo.ResultInfo;
import com.atwisdom.star.core.bsl.modelClass.workCenter.Impl.WorkCenterInstanceBslServiceImpl;
import com.atwisdom.star.core.bsl.modelClass.workCenter.Impl.WorkCenterModelBslServiceImpl;
import com.atwisdom.star.exception.pojo.BusinessException;
import com.atwisdom.star.log.aop.StarAnnotation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/workCenter")
public class WorkCenterController {
    private WorkCenterModelBslServiceImpl workCenterModelBslService;
    private WorkCenterInstanceBslServiceImpl workCenterInstanceBslService;

    @Autowired
    public void setWorkCenterModelBslService(WorkCenterModelBslServiceImpl workCenterModelBslService) {
        this.workCenterModelBslService = workCenterModelBslService;
    }

    @Autowired
    public void setWorkCenterInstanceBslService(WorkCenterInstanceBslServiceImpl workCenterInstanceBslService) {
        this.workCenterInstanceBslService = workCenterInstanceBslService;
    }

    @StarAnnotation
    @PostMapping(value = "/model")
    public ResultInfo<?> workCenterModel(@RequestBody List<ActionData<JSONObject>> actionDataList) throws BusinessException {
        return workCenterModelBslService.responseFactory(actionDataList);
    }

    /**
     * @param actionDataList 接收参数据
     * @return 返回结果
     * @throws BusinessException 异常
     */
    @StarAnnotation
    @PostMapping(value = "/instance")
    public ResultInfo<?> workCenterInstance(@RequestBody List<ActionData<JSONObject>> actionDataList) throws BusinessException {
        return workCenterInstanceBslService.responseFactory(actionDataList);
    }
}
